package com.tamtamy.jtta.data.xml;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.tamtamy.jtta.data.UserStatsList;
import com.tamtamy.jtta.exception.NoResultException;

public class XMLUserStatsList extends UserStatsList {
	
	private static final long serialVersionUID = 1730081665635685673L;
	
	private static final String KCLUSERSTATS = "it.reply.tt.rest.entity.KcLUserStats";
	
	public XMLUserStatsList(Document xmlDocument) throws NoResultException{
		super();
		
		NodeList userStatsNodeList = xmlDocument.getElementsByTagName(KCLUSERSTATS);
		if (userStatsNodeList == null || userStatsNodeList.getLength()==0){
			throw new NoResultException("No " + KCLUSERSTATS + " element found");
		}
		for (int i = 0; i < userStatsNodeList.getLength(); i++) {
			Node userStatsNode = userStatsNodeList.item(i);
			XMLUserStats xmlUserStats = new XMLUserStats(userStatsNode.getOwnerDocument());
			this.add(xmlUserStats);  
		}	
		
	}
}
